package com.mifengs.mall.ui.share;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.mifengs.mall.R;
import com.mifengs.mall.adapter.ShareRankAdapter;
import com.mifengs.mall.entity.RedPacket;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 *
 *
 */
public class RankingFragment extends Fragment {


    @BindView(R.id.rv_list)
    RecyclerView mRvList;

    private int mType;

    public RankingFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mType = getArguments().getInt("type");
        }
    }

    public static RankingFragment newInstance(int type) {
        RankingFragment fragment = new RankingFragment();
        Bundle args = new Bundle();
        args.putInt("type", type);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_ranking, container, false);
        ButterKnife.bind(this, view);
        init();
        return view;
    }

    private void init() {
        mRvList.setLayoutManager(new LinearLayoutManager(getContext()));
        ShareRankAdapter adapter = new ShareRankAdapter(getData());
        mRvList.setAdapter(adapter);
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }


    public ArrayList<RedPacket> getData(){
        ArrayList<RedPacket> redPacketList = new ArrayList<>();
        redPacketList.add(new RedPacket());
        redPacketList.add(new RedPacket());
        redPacketList.add(new RedPacket());
        redPacketList.add(new RedPacket());
        redPacketList.add(new RedPacket());
        redPacketList.add(new RedPacket());
        return redPacketList;
    }
}
